<template>
  <!-- 国际化语言菜单按钮 -->
  <el-dropdown @command="changeLang">
    <span class="el-dropdown-link">
      <svg-icon icon-class="language" />
    </span>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item :disabled="$i18n.locale == 'en'" command="en"
        >English</el-dropdown-item
      >
      <el-dropdown-item :disabled="$i18n.locale == 'zh'" command="zh"
        >中文</el-dropdown-item
      >
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
import Cookies from 'js-cookie'

export default {
  methods: {
    changeLang (lang) {
      // 默认语言：
      this.$i18n.locale = lang
      //   改为什么语言我就把他存起来，下次刷新调用
      Cookies.set('lang', lang)
      //   饿了么ui不会跟着自己的语言包刷新！所以自己刷新
      this.$router.go(0)
    }
  }
}
</script>

<style></style>
